package com.wuchengdong.web.controller;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wuchengdong.web.extend.utils.R;
import com.wuchengdong.web.pojo.User;
import com.wuchengdong.web.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping
    public R<List<User>> getAll() {
        return R.success(userService.list());
    }

    @GetMapping("/getById")
    public R<User> getById(User user) {
        return R.success(userService.getById(user.getId()));
    }

    @PostMapping
    public R<String> updateUser(@RequestBody User user) {
        userService.saveOrUpdate(user);
        return R.success("保存成功");
    }

}
